//Define some parameters and struct

struct gpt_regs {
	volatile unsigned int scalercnt;		/* 0x00 */
	volatile unsigned int scalerload;		/* 0x04 */
	volatile unsigned int configreg;		/* 0x08 */
	volatile unsigned int dummy1;		/* 0x0C */
	volatile unsigned int counter;		/* 0x10 */
	volatile unsigned int reload;		/* 0x14 */
	volatile unsigned int control;		/* 0x18 */
	volatile unsigned int dummy2;		/* 0x1C */
};

struct gpio_regs {
	volatile unsigned int din;		/* 0x00 */
	volatile unsigned int dout;		/* 0x04 */
	volatile unsigned int dir;		/* 0x08 */
	volatile unsigned int imask;		/* 0x0C */
	volatile unsigned int ipol;		/* 0x10 */
	volatile unsigned int iedge;		/* 0x14 */
};

struct uart_regs 
{
   volatile unsigned int data;		/* 0x00 */
   volatile unsigned int status;		/* 0x04 */
   volatile unsigned int control;		/* 0x08 */
   volatile unsigned int scaler;		/* 0x0C */
};

struct irq_regs {
    volatile unsigned int irqlevel;		/* 0x00 */
    volatile unsigned int irqpend;		/* 0x04 */
    volatile unsigned int irqforce;		/* 0x08 */
    volatile unsigned int irqclear;		/* 0x0C */
    volatile unsigned int mpstatus;		/* 0x10 */
    volatile unsigned int dummy[11];		/* 0x14 - 0x3C */
    volatile unsigned int irqmask;		/* 0x40 */
};

//base address
#define GPT_ADD 0x80000300	//gptimer
#define GPIO_ADD 0x80000500	//gpio
#define UART_ADD 0x80000100	//uart
#define IRQ_ADD 0x80000200	//irqmp

#define IPLD_ADD 0xa1000034		//0x40002000		//ipload

#define UID_ADD	0xB1012288		//0x40002004		//user ID

#define BIT22_ADD 0xB0000028		//0x40002008		//Bit 22
#define BIT23_ADD 0xB000002C		//0x4000200C		//Bit 23

#define M_ADD 0xB1012200		//0x40002010	//M1~16 & N1~16

#define SYW_ADD 0xB0000000		//0x40002090;		//SYW1~8

#define E2_ADD 0xB1000000		//0x40002300;		//AU E2 address

#define D0_ADD 0xB0000000		//0x40002200;		//AU E2 address
#define D1_ADD 0xB0000010		//0x40002210;		//AU E2 address

#define TEMP_ADD 0x40000004		//0x40002100;		//store compensation data or M&N data

//timer setting
#define COUNTER_TH 0xFFFFE15F		//(0xFFFFFFFF - 0x00001EA0)

//state machine definition
#define INIT 0x00000000
#define UART_R0 0x00000001
#define UART_R1 0x00000002
#define UART_R2 0x00000003
#define UART_R3 0x00000004
#define UART_F1 0x00000005
#define UART_F2 0x00000006
#define UART_F3 0x00000007
#define UART_F4 0x00000008
#define UART_WE2 0x00000009
#define UART_T4 0x0000000A
#define GPIO_H 0x0000000B
#define GPIO_D 0x0000000C
#define GPIO_C 0x0000000D
